<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the  Academic Free License (AFL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to support@zprofess.com so we can send you a copy immediately.
 *
 * @category   	Prestashop module
 * @package		Membership
 * @version 	1.0
 * @author 		Nguyen Dinh Nhat <nguyendnhat@gmail.com>
 * @copyright   Copyright (c) 2012 ZPROFESS. (http://zprofess.com)
 * @license    	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/**
 * @see Zmodule
 */

require(_PS_MODULE_DIR_.'zgallery/lib/zprofess/Zmodule.php');

class ZgalleryConfig extends Zmodule {	
	/**
	 * Destroy var config
	 * @return boolean
	 */
 	public function destroyConfiguration () {
		Configuration::deleteByName('PL_PAGE_COMMENT');
		return true;
	} 
    /**
     * Init var config
     * @return boolean
     */
	public function initConfiguration() {
		Configuration::updateValue('PL_PAGE_COMMENT',50);
		return true;
	}
	
	/**
	 * process date post from form config
	 * 
	 * @return void
	 */
	private function _postProcess()
	{
		if (Tools::isSubmit('submitGConfiguration')){
			Configuration::updateValue('PL_PAGE_COMMENT',Tools::getValue('PL_PAGE_COMMENT'));
			echo $this->displayConfirmation($this->l('General Settings are updated'));		
		}
	}
	
	/*
	 * Display configuration page of module.
	 * 
	 * @return string html
	 */
	public function getContent() 
	{
		$this->_postProcess();
		return '<h2>'.$this->displayName.'</h2>'.$this->_displayForm();
	}
	
	/**
	 * display Form Config (All tab)
	 * 
     * @return string html
	 */
	protected function _displayFormConfig()
	{
		global $cookie;
		$this->_html .= '<br class="clear" /> <br/>
			<form name="" method="post" action="'.$_SERVER['REQUEST_URI'].'">
				<fieldset style="float:left;width: 900px; ">
					<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings Gallery').'</legend>
					'.$this->addElement('text',array('label'=>'Consideration of comment is displayed on 1 page','name'=>'PL_PAGE_COMMENT','value'=>'PL_PAGE_COMMENT','note'=>'')).'
					'.$this->addElement('button',array('name'=>'submitGConfiguration','value'=>'Save')).'
				</fieldset >
			</form>
		';
	}
	
	/**
	 * Display form General Settings
	 * 
	 * @return string html
	 */
	private function _displayFormGeneral()
	{
		return '';
	}
	
}